# import  time
# print('当前时间为：', time.strftime('%Y-%m-%d %H:%m:%S', time.localtime(time.time())))
#
# user_date = ["guosiwen", "liliumang", "jianglaoban"]
# password_date = ["111", "222", "333"]
# vip_user_date = ["guojunbin"]
# vip_password = ["123"]
#
# count = 3
# while True:
#     count -= 1
#
#     username = input("账号：")
#     password = input("密码：")
#
#     if username in user_date or username in vip_user_date:
#         # 验证账号
#         if password in password_date or password in vip_password:
#             print('欢迎', username,'登录网址')
#             # 验证是否为VIP
#             if username in vip_user_date:
#                 # 再判断密码是否正确
#
#                 if password in vip_password:
#                     count = 10  # 代表有10次查询课表的机会
#                     print("Dear VIP!")
#                     print("Welcome ", username, "to use this website")
#                     print("You have ", count, " chances")

# info = '''------goods list-----
# %s
# %s
# %s
# %s
# %s
# ''' % (goods[0][0], goods[1][0], goods[2][0], goods[3][0])



goods = [
        ("nub", "《书籍名称》", '价格'),
        ("01", "《活着》", 14),
        ("02", "《呐喊》", 16),
        ("03", "《在雨夜中呐喊》", 19),
        ("04", "《会飞的猪》", 25)]
shopping_car = []
# 加入购物车选项
balance = input("请输入您现有余额:")
# 插入零钱,用户输入

# 类似循环
while True:
    balance = int(balance)
    # 加入for循环
    for item in goods:
        print(item)
    choice = input('请输入您想要查询的商品编号：')
    if choice.isdigit():
        choice = int(choice)
    # 商品有5种，因为代码中-1（nub），所以实际只有四种商品
    if choice >= 0 and choice < 5:
        # 因为前面在价格那里用了双引号，所以这边要添加int去输出
        if balance >= (int(goods[choice][2])):
            # print(goods[choice][1])
            balance = balance - int(goods[choice][2])
            shopping_car.append(int(goods[choice][1]))
            print("您已把%s,添加到购物车中，当前您的余额是%s"%(goods[choice][2],balance))
            print(shopping_car)
            print("继续购买，退出购买请按”Q“退出")
        else:
            print("无此商品信息，请根据购物栏选择您所要购买的商品，请重新输入，更多就商品敬请期待...")
    elif choice == 'q':
        print("购物车清单：",shopping_car)











# print(info)
# user_input_ID = input("请输入商品的ID：")
# for good in goods:
#     print(good)
#     # 判断商品的ID是否正确
#     if user_input_ID == good[0]:
#         # 判断用户的余额是否够用
#         if int(good[2]) < int(支付宝余额):
#             # 把商品加进list
#             user_shop_list.append(good)
#             # 扣除支付宝余额
#     else:
#         print("您输入的商品信息有问题，请输入正确的商品ID")
